package io.litchi.starter.oss;

import io.litchi.starter.oss.dto.CompletedPartDto;
import io.litchi.starter.oss.dto.InitiateUploadResponse;
import io.litchi.starter.oss.dto.UploadPartResponse;

import java.io.InputStream;
import java.util.List;


public interface LitchiOssClient {

    void createBucketIfNotExists(String bucketName);

    /**
     * 上传文件
     */
    String upload(String key, InputStream inputStream, long size, String contentType);

    /**
     * 指定上传bucketName
     */
    String upload(String key, InputStream inputStream, long size, String contentType,String newBucketName);

    /**
     * 下载文件
     */
    InputStream download(String key);

    /**
     * 删除文件
     */
    void delete(String key);

    /**
     * 获取文件外链（临时）
     */
    String getTemporaryUrl(String key, int expireSeconds);

    /**
     * 获取公开可访问的 URL（仅适用于 public-read 权限的 bucket）
     * 格式如：https://bucket.oss-cn-beijing.aliyuncs.com/path/to/file.jpg
     */
    String getPublicUrl(String key);

    //以下用文件分片上传

    /**
     * 初始化分片上传
     * */
    public InitiateUploadResponse initiateMultipartUpload(String fileName, String contentType);

    /*
    * 上传分片
    * */
    public UploadPartResponse uploadPart(String uploadId, String key, int partNumber, byte[] data);

    /*
    * 查询已上传分片
    * */
    public List<UploadPartResponse> listUploadedParts(String uploadId, String key);

    /*
    * 完成上传
    * */
    public String completeMultipartUpload(String uploadId, String key, List<CompletedPartDto> partDtoList);

    /*
    * 终止上传
    * */
    public void abortMultipartUpload(String uploadId, String key);
}
